package com.dongdong.bookstore.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author chiangkai
 * @date 2021-10-18
 * @email chiangkk@163.com
 */
@Configuration
public class CustomWebMvcConfig implements WebMvcConfigurer {
    /**
     * 静态资源处理
     *  <a href="https://www.jianshu.com/p/07c598beb8d8?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation">参考url</a>
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
        registry.addResourceHandler("/swagger/**").addResourceLocations("classpath:/static/swagger/");
        registry.addResourceHandler("/static/**").addResourceLocations("/static/"); //自定义一个资源目录,用来放置静态资源
    }
}
